Get values from listView

Following on from my previous post, im struggling to get and print the values which the user inputs from a multi-select listView.

Code attached.

When i try to print i just get nothing.
 

//select users
 
/*

*/
 
Module m = current
Baseline b
 
string users
string     dummy[]      ={}
User user
int     userCount       =0
int     i                       =0
 
//throw up a dialog box to get variables        
DB selectusersDB = create ("Select users", styleStandard)
DBE userchoiceDBE = listView (selectusersDB, listViewOptionMultiselect|listViewOptionCheckboxes, 200, 10, dummy)
 
//put the db variables into dxl variable
void getvariables (DB selectusersDB)  {
        users = get (userchoiceDBE)
        print users}
ok (selectusersDB, "&OK", getvariables)
realize(selectusersDB)
 
insertColumn(userchoiceDBE, 0, "User", 190, iconNone)
 
//list attributes and insert into choice element
for user in userList do 
{
        string uname = user.name
        insert(userchoiceDBE, userCount, uname"") 
        userCount++
}
 
//show
show (selectusersDB)

liamc - Thu Apr 22 11:02:55 EDT 2010

Re: Get values from listView
llandale - Thu Apr 22 12:30:43 EDT 2010

The 'string get(DBE)' function for listViews gets the selected option. Your code works, and will print the selected user name so long as you select one.

I don't like using the 'ok' function, since it auto-closes the dialog. Usually, you want to do some checking first; in this case make sure that a user is in fact selected. If so, then hide(selectusersDB) and destroy(selectusersDB).

  • Louie